//
//  HttpClient.m
//  iFlick
//
//  Created by vhly on 10-8-26.
//  Copyright 2010 xhzhang. All rights reserved.
//

#import "HttpClient.h"


@implementation HttpClient

@synthesize delegate;


- (void)submitRequest:(NSMutableURLRequest *)req{
	NSInteger len = [requests count];
	if (len > 0) {
		if (delegate) {
			[delegate submitStart];
		}
		NSURLConnection *conn;
		conn = [NSURLConnection connectionWithRequest:req delegate:self];
		if (delegate) {
			[delegate submitStart];
		}
	}
}

- (void)connectionDidFinishLoading:(NSURLConnection *)connection{
	if (delegate) {
		[delegate submitFinsihed];
	}
}

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error{
	if (delegate) {
		[delegate submitFinsihed];
	}
}

- (void)connection:(NSURLConnection *)connection didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite{
	if (delegate) {
		[delegate onProcessSend:totalBytesWritten total:totalBytesExpectedToWrite];
	}
}

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{

}

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{

}

- (void)dealloc{
	[requests release];
	[super dealloc];
}

@end
